<?php $this->load->view('header'); ?>
<?php
	$data = $this->recruitment_model->getAllIndustry();
	$data = $data->result_array();
	$name_city = $this->recruitment_model->getNameCity();
	$name_city = $name_city->result();
	// echo "<pre>";
	// print_r($name_city);
	// echo "</pre>";
?>
<div class="wrap-content">
	<div class="container">
		<div style="margin-top:30px"></div>
		<div class="row">
			<div class="col-lg-12">
			<div class="row">
				<form method="POST" action="<?php echo site_url('search/job');?>">
					<div class="frm-search frm-search-freelancer col-lg-5 col-xs-5 col-md-5">
			            <input type="text" class="form-control" name = "job_name" id="exampleInputEmail1" placeholder='"Nhập từ khóa công việc"'>
			        </div> <!-- frm-search -->
			        <div class="col-lg-3 col-md-3 col-xs-3">
			        	<select class="form-control" name="industry" id="industry">
			        		<option value="0">Chọn ngành nghề</option>
			        		<?php 
			        			foreach ($data as $value) {
			        				echo '<option value="'.$value["industry_id"].'">'.$value["industry_name"].'</option>';
			        			}
			        		?>
			            </select>
			        </div><!-- end of ngành nghề-->
			        <div class="col-lg-3 col-md-3 col-xs-3">
			        	<select class="form-control" name="workplace" id="workplace">
			            	<option value="0">Chọn địa điểm</option>
			            	<?php
			            		foreach ($name_city as $value) {
			            			echo "<option value='".$value->location_id."'>".$value->location_name."</option>";
			            		}
			            			 
			            		
			            	?>
			            </select>
			        </div><!-- end of workplace-->
			        <div class="col-lg-1 col-xs-1 col-md-1">
			        	<button type="submit" class="icon-lookup" id="btn_submit"></button>
			        </div>
				</form> 
			</div>
				       
			</div>	
		</div>
		<div class="row">
			<div class="col-lg-12">
        	<div class="re-title">
        		<h3>tìm thấy <?php echo count($allRecruitment->result_array()); ?> việc làm phù hợp</h3>
        	</div>
        	<div class="re-result">
        		<div class="re-list">
	        			<table class="table table-hover">
	        				<thead class="table-header">
						      <tr>
						         <th>STT</th>
						         <th>Vị trí tuyển dụng</th>
						         <th>Địa điểm</th>
						         <th>Ngày đăng</th>
						         <th>Ngày hết hạn</th>
						      </tr>
						   </thead>
						   <tbody>
						   	<?php
						   		$i = 1;
						   		foreach($allRecruitment->result_array() as $value){
						   		$name_city = $this->recruitment_model->getNameCity($value['location']);
						   			
						   	?>	<tr class="tbody">
						   			<td><?php echo $i;$i++;?></td>
						   			<td class="table-row"><a href="<?php echo site_url().'/recruitment/showSingleRecruitment/'.$value['job_id']."/".$value['industry_id'];?>"><?php echo $value['job_name'];?></a></td>
						   			<td>
						   				<?php 
						   					$temp = $this->recruitment_model->getNameCityById($value['location']);
						   					echo $temp->location_name;
						   				?>
						   			</td>
						   			<td><?php echo $value['created_at'];?></td>
						   			<td><?php echo $value['expired_at'];?></td>
						   		</tr>
						   	<?php
						   		}
						   	?>
						   </tbody>
	        			</table>
	        		</div>
	        	</div>
        </div>
		</div>
		

        <div class="col-lg-12" style="text-align:center">
        	<?php 
           		if(isset($pagination))
           		echo $pagination;
           	?>
        </div>	
		
	</div>
</div>

<script type="text/javascript">
	$(document).ready(function(){
		$("#btn_submit").click(function(e){
			var industry = $("#industry").val();
			var workplace = $("#workplace").val();
			if(industry == 0 && workplace == 0){
				e.preventDefault();
				$("#myModal").modal('show');
			}
		});
		
	});
</script>

<div class="modal fade" id="myModal">
    <div id="show_result"></div>
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">Notification</h4>
            </div>
            <div class="modal-body">
            	<h3><center><strong>Please choose at least a Industry or Workplace</strong></center></h3>
            </div>
        </div>
    </div>
</div>
<?php $this->load->view('footer'); ?>